package com.charging.business.enums;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public enum ProvinceType {
   NATION("路网中心", "0", "路网中心", "全国", 0, "lwzx") ,
   BEI_JING("北京市", "11", "北京", "京", 0, "bj") ,
   TIAN_JIN("天津市", "12", "天津", "津", 1, "tj") ,
   HE_BEI("河北省", "13", "河北", "冀", 2, "hb") ,
   SHAN_XI("山西省", "14", "山西", "晋", 3, "sx") ,
   NEI_MENG_GU("内蒙古自治区", "15", "内蒙古", "蒙", 4, "nmg") ,
   LIAO_NING("辽宁省", "21", "辽宁", "辽", 5, "ln") ,
   JI_LIN("吉林省", "22", "吉林", "吉", 6, "jl") ,
   HEI_LONG_JIANG("黑龙江省", "23", "黑龙江", "黑", 7, "hlj") ,
   SHANG_HAI("上海市", "31", "上海", "沪", 8, "sh") ,
   JIANG_SU("江苏省", "32", "江苏", "苏", 9, "js") ,
   ZHE_JIANG("浙江省", "33", "浙江", "浙", 10, "zj") ,
   AN_HUI("安徽省", "34", "安徽", "皖", 11, "ah") ,
   FU_JIAN("福建省", "35", "福建", "闽", 12, "fj") ,
   JIANG_XI("江西省", "36", "江西", "赣", 13, "jx") ,
   SHAN_DONG("山东省", "37", "山东", "鲁", 14, "sd") ,
   HE_NAN("河南省", "41", "河南", "豫", 15, "hn") ,
   HU_BEI("湖北省", "42", "湖北", "鄂", 16, "hb") ,
   HU_NAN("湖南省", "43", "湖南", "湘", 17, "hn") ,
   GUANG_DONG("广东省", "44", "广东", "粤", 18, "gd") ,
   GUANG_XI("广西壮族自治区", "45", "广西", "桂", 19, "gx") ,
   CHONG_QING("重庆市", "50", "重庆", "渝", 20, "cq") ,
   SI_CHUAN("四川省", "51", "四川", "川", 21, "sc") ,
   GUI_ZHOU("贵州省", "52", "贵州", "贵", 22, "gz") ,
   YUN_NAN("云南省", "53", "云南", "云", 23, "yn") ,
   SHAAN_XI("陕西省", "61", "陕西", "陕", 24, "sx") ,
   GAN_SU("甘肃省", "62", "甘肃", "甘", 25, "gs") ,
   QING_HAI("青海省", "63", "青海", "青", 26, "qh") ,
   NING_XIA("宁夏回族自治区", "64", "宁夏", "宁", 27, "nx") ,
   XIN_JIANG("新疆维吾尔自治区", "65", "新疆", "新", 28, "xj") ,
   HAI_NAN("海南省", "46", "海南", "琼", 29, "hn") ,
   XI_ZANG("西藏自治区", "54", "西藏", "藏", 30, "xz") ,
   QIAN_ZHUANG("前装发行", "99", "前装", "前", 31, "qz") ;

    private final String fullName;
    private final String code;
    private final String shortName;
    private final String nickName;
    private final int partition;
    private final String namePinyin;

    ProvinceType(String fullName, String code, String shortName, String nickName, int partition, String namePinyin) {
        this.fullName = fullName;
        this.code = code;
        this.shortName = shortName;
        this.nickName = nickName;
        this.partition = partition;
        this.namePinyin = namePinyin;
    }

    public static ProvinceType fromCode(String code) {
        ProvinceType provinceType = fromCodeNull(code);
        if (null != provinceType) {
            return provinceType;
        }
        throw new RuntimeException("省份编号不存在：" + code);
    }

    /**
     * 无数据返回null
     *
     * @param code
     * @return
     */
    public static ProvinceType fromCodeNull(String code) {
        ProvinceType[] values = values();
        int length = values.length;

        for (int i = 0; i < length; ++i) {
            ProvinceType type = values[i];
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }

    public static ProvinceType fromShortName(String shortName) {
        ProvinceType[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            ProvinceType type = var1[var3];
            if (type.getShortName().equals(shortName)) {
                return type;
            }
        }

        throw new RuntimeException("省份简称不存在：" + shortName);
    }

    public static ProvinceType fromName(String name) {
        ProvinceType[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            ProvinceType type = var1[var3];
            if (type.name().equals(name)) {
                return type;
            }
        }

        throw new RuntimeException("省份名称不存在：" + name);
    }

    public static List<ProvinceType> getProvinces() {
        List<ProvinceType> lists = new ArrayList<>();
        ProvinceType[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            ProvinceType type = var1[var3];
            if (type != NATION) {
                lists.add(type);
            }
        }

        return lists;
    }

    public static List<ProvinceType> getAllProvinces() {
        List<ProvinceType> proList = new ArrayList<>();
        ProvinceType[] var1 = values();
        int var2 = var1.length;

        proList.addAll(Arrays.asList(var1).subList(0, var2));

        proList.sort((p1, p2) -> {
            return p1.getCode().compareTo(p2.getCode());
        });
        return proList;
    }

    public static ProvinceType getLocal() {
        return QING_HAI;
    }

    public ProvinceType[] withOutNation() {
        ProvinceType[] rs = new ProvinceType[29];
        int i = 0;
        ProvinceType[] var3 = values();
        int var4 = var3.length;

        for (int var5 = 0; var5 < var4; ++var5) {
            ProvinceType province = var3[var5];
            if (province != NATION) {
                rs[i] = province;
                ++i;
            }
        }

        return rs;
    }

    public String getFullName() {
        return this.fullName;
    }

    public String getCode() {
        return this.code;
    }

    public String getShortName() {
        return this.shortName;
    }

    public String getNickName() {
        return this.nickName;
    }

    public int getPartition() {
        return this.partition;
    }

    public String getNamePinyin() {
        return this.namePinyin;
    }
}
